package com.app.bimo.commonbusiness.network;

import java.io.IOException;

import io.reactivex.Observer;
import okhttp3.Interceptor;
import okhttp3.Response;

public class DownloadInterceptor implements Interceptor {
    private Observer<Integer> observer;

    public DownloadInterceptor(Observer<Integer> observer) {
        this.observer = observer;
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Response originalResponse = chain.proceed(chain.request());
        return originalResponse.newBuilder()
                .body(new DownloadResponseBody(originalResponse.body(), observer))
                .build();
    }
}
